import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { SArenaToplist } from "../../../../../Message/Public/SArenaToplist";
import { CareerConfig } from "../../../resource/CareerConfig";
import { Cache } from "../../../cache/Cache";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class ArenaTopCellRenderer
    
    export  class ArenaTopCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._line = ResouceConst.getScaleBitmap("SplitLine");
            this._line.width = 460;
            this._line.height = 2;
            this.addChild(this._line);
            this._tfOther = new GTextFormat(FontUtil.songtiName, 12, 11661311);
            this._tfOther.align = flash.text.TextFormatAlign.CENTER;
            this._tfSelf = new GTextFormat(FontUtil.songtiName, 12, 6350622);
            this._tfSelf.align = flash.text.TextFormatAlign.CENTER;
            this._tfRank = ObjCreate.createTextField("", 0, 8, 60, 20, this, this._tfOther);
            this._tfName = ObjCreate.createTextField("", 60, 8, 90, 20, this, this._tfOther);
            this._tfLevel = ObjCreate.createTextField("", 150, 8, 60, 20, this, this._tfOther);
            this._tfCareer = ObjCreate.createTextField("", 210, 8, 60, 20, this, this._tfOther);
            this._tfScore = ObjCreate.createTextField("", 270, 8, 60, 20, this, this._tfOther);
            this._tfWinPer = ObjCreate.createTextField("", 330, 8, 60, 20, this, this._tfOther);
            return;
        }

        /* internal  */addListeners(): void
        {
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "sarenatoplist") 
            {
                this._scoreData = arg1 as SArenaToplist;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfRank.text = this._scoreData.rank.toString();
            this._tfName.text = this._scoreData.name;
            this._tfLevel.text = this._scoreData.level.toString();
            this._tfCareer.text = CareerConfig.instance.getInfoByCode(this._scoreData.career).name;
            this._tfScore.text = this._scoreData.mark.toString();
            this._tfWinPer.text = this._scoreData.winPer.toString() + "%";
            if (Cache.instance.role.entityInfo.name != this._scoreData.name) 
            {
                this._tfRank.setTextFormat(this._tfOther);
                this._tfName.setTextFormat(this._tfOther);
                this._tfLevel.setTextFormat(this._tfOther);
                this._tfScore.setTextFormat(this._tfOther);
                this._tfCareer.setTextFormat(this._tfOther);
                this._tfWinPer.setTextFormat(this._tfOther);
                if (this._star && this._star.parent) 
                {
                    this._star.parent.removeChild(this._star);
                }
            }
            else 
            {
                this._tfRank.setTextFormat(this._tfSelf);
                this._tfName.setTextFormat(this._tfSelf);
                this._tfLevel.setTextFormat(this._tfSelf);
                this._tfScore.setTextFormat(this._tfSelf);
                this._tfCareer.setTextFormat(this._tfSelf);
                this._tfWinPer.setTextFormat(this._tfSelf);
                if (!this._star) 
                {
                    this._star = GlobalClass.getBitmap(ImagesConst.ChatGuildMember_star);
                    this._star.x = 0;
                    this._star.y = 6;
                }
                this.addChild(this._star);
            }
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_line: ScaleBitmap;

        /* internal */ /* var */_star: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfWinPer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfSelf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_tfOther: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_scoreData: SArenaToplist;
    }
